<script setup>
import { geUpdateInfoAPi } from "../../http/http";
import MyDatails from "../../components/MyDatails.vue";
import { useRoute, useRouter } from "vue-router";
import { ref } from "vue";
const { push } = useRouter();
const route = useRoute();
const id = route.query.id;
// 修改用户

const afterRead = async (file) => {
  let obj = {
    id: id,
    img: file.content,
  };
  let res = await geUpdateInfoAPi(obj);
  if (res.code == 200) {
    push("/Personalnfo");
  }
};
</script>
<template>
  <div class="upimg">
    <!-- 头部 -->
    <MyDatails>
      <template #left>
        <van-icon name="arrow-left" @click="$router.back" />
      </template>
      <template #text>
        <h3>修改头像</h3>
      </template>
    </MyDatails>
    <div class="upbox">
      <van-uploader
        :preview-image="false"
        :after-read="afterRead"
        @oversize="onOversize"
      />
    </div>
  </div>
</template>

<style lang="scss" scoped>
.upbox {
  text-align: center;
}
</style>
